﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace DbSharp.Framework.CaseFile.Parser
{
    class OutputSettingAttrParser
    {
        public static void OverrideSetting(IResultsetOutputSetting outputSetting, XElement outputSettingElmt)
        {
            if (outputSettingElmt == null)
                return;

            XAttribute attribute;
            attribute = outputSettingElmt.Attribute("exportRecordCount");
            if (attribute != null)
            {
                long count;
                if (long.TryParse(attribute.Value, out count))
                {
                    outputSetting.ExportRecordCount = count;
                }
            }

            attribute = outputSettingElmt.Attribute("wrapStringByCDATA");
            bool wrapedByCDATA = false;
            if (attribute != null)
            {
                wrapedByCDATA = string.Equals(attribute.Value.Trim(), "TRUE",
                    StringComparison.OrdinalIgnoreCase);
                outputSetting.WrapStringByCDATA = wrapedByCDATA;
            }
            
        }
    }
}
